﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Utility
{
    public static class RandomUtil
    {
        private static char[] constant = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
        public static string GetRandomNum(int length)
        {
            string baseString = string.Empty.PadRight(length, ' ');
            Random r = new Random();

            StringBuilder sb = new StringBuilder(baseString);
            for (int p = 0; p < length; p++)
            {
                sb[p] = constant[r.Next(0, 9)];
            }

            return sb.ToString();
        }

        public static string GetRandomString(int stringLength)
        {
            string baseString = string.Empty.PadRight(stringLength, ' ');
            Random r = new Random();

            StringBuilder sb = new StringBuilder(baseString);
            for (int p = 0; p < stringLength; p++)
            {
                sb[p] = constant[r.Next(0, 36)];
            }

            string key = sb.ToString();


            return key;
        }
    }
}
